package firstStage.part10;

import java.util.ArrayList;

/**
 * @ClassName: [ArrayListDemo1]
 * @Description: 集合中常用的方法
 * @Author: [黄劲松]
 * @CreateDate: [2021-02-07]
 * @Version: [v1.0]
 */
/*public boolean remove(Objecto)
        删除指定的元素，返回删除是否成功
public E remove(int index)
        删除指定索弓|处的元素，返回被删除的元素
public E set(int index,E element)
        修改指定索引处的元素，返回被修改的元素
public E get(int index)
        返回指定索引处的元素
public int size()
        返回集合中的元素的个数*/
public class ArrayListDemo1 {
    public static void main(String[] args) {
        //创建集合
        ArrayList<String> arrayList = new ArrayList<String>();
        arrayList.add("hello");
        arrayList.add("world");
        arrayList.add("Java");
        arrayList.add(1, "python");
        System.out.println("arrayList：" + arrayList);
        System.out.println(arrayList.remove("world"));
        System.out.println("arrayList：" + arrayList);

        ArrayList<String> arrayList1 = new ArrayList<String>();
        arrayList1.add("hello");
        arrayList1.add("world");
        arrayList1.add("Java");
        arrayList1.add(1, "python");
        System.out.println("arrayList1：" + arrayList1);
        System.out.println(arrayList1.remove(0));
        System.out.println("arrayList1：" + arrayList1);

        ArrayList<String> arrayList2 = new ArrayList<String>();
        arrayList2.add("hello");
        arrayList2.add("world");
        arrayList2.add("Java");
        arrayList2.add(1, "python");
        System.out.println("arrayList2：" + arrayList2);
        System.out.println(arrayList2.set(0, "javaEE"));
        System.out.println("arrayList2：" + arrayList2);

        ArrayList<String> arrayList3 = new ArrayList<String>();
        arrayList3.add("hello");
        arrayList3.add("world");
        arrayList3.add("Java");
        arrayList3.add(1, "python");
        System.out.println("arrayList3：" + arrayList3);
        System.out.println(arrayList3.get(0));
        System.out.println(arrayList3.get(3));

        ArrayList<String> arrayList4 = new ArrayList<String>();
        arrayList4.add("hello");
        arrayList4.add("world");
        arrayList4.add("Java");
        arrayList4.add(1, "python");
        System.out.println("arrayList4：" + arrayList4);
        System.out.println(arrayList4.size());
    }
}
